package com.xintouyun.medicine.servlet;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import com.xintouyun.medicine.entity.ShopAttention;
import com.xintouyun.medicine.entity.User;
import com.xintouyun.medicine.service.ShopService;
import com.xintouyun.medicine.service.impl.ShopServiceImpl;
@WebServlet("/AttentionAddServlet")
public class AttentionAddServlet extends HttpServlet{

	
	@Override
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		HttpSession session = request.getSession();
		User user = (User) session.getAttribute("loginUser");
		
		String sid = request.getParameter("sid");
		
		ShopAttention shopAttention = new ShopAttention();
		shopAttention.setSid(Integer.parseInt(sid));
		shopAttention.setUid(user.getUid());
		ShopService shopService = new ShopServiceImpl();
		int i = shopService.save(shopAttention);
		
		if(i>0) {
			response.sendRedirect("index");
		}
		
	}
	
	@Override
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		this.doPost(request, response);
	}
}
